/*
 * envelop_can_28335.h
 *
 *  Created on: 2013-6-25
 *      Author: dylan
 */

#ifndef ENVELOP_CANB_28335_H_
#define ENVELOP_CANB_28335_H_

void ecanb_init();

void ecanb_cfg_begin();
void ecanb_cfg_end();

void ecanb_cfg_bps( const unsigned long& bps = 0xF4240 /*1M*/ );
void ecanb_cfg_mbsDir( const unsigned long& rx=0xFFFF0000 );
void ecanb_cfg_mbsOverWrite( const unsigned long& masks = 0xFFFE0000 );
void ecanb_cfg_mbId( const unsigned short& mailBox,const unsigned int& id,const unsigned long& mask );
void ecanb_cfg_mbTx( const unsigned short& mailBox,const unsigned short& level=1 );

unsigned short ecanb_mbBusy( const unsigned short& mailBox );
unsigned short ecanb_mbReady( const unsigned short& mailBox );

void ecanb_mbTx( const unsigned short* buf,const unsigned short& size, const unsigned short& mailBox );
unsigned short ecanb_mbRx( unsigned short* buf,const unsigned short& size, const unsigned short& mailBox );

unsigned short ecanb_mbsTx( const unsigned short* buf,const unsigned short& size,const unsigned short& mailBoxStart = 0,unsigned short num = 16 );
unsigned short ecanb_mbsRx( unsigned short* buf,const unsigned short& size, const unsigned short& mailBoxStart = 16 ,unsigned short num = 16 );

unsigned short ecanb_mbsBusy( const unsigned short& mailBoxStart = 0,unsigned short num = 16 );

void ecanb_statue( unsigned long& s );

unsigned short ecanb_txErrc();
unsigned short ecanb_rxErrc();

unsigned long ecanb_debug();

#endif /* ENVELOP_CAN_28335_H_ */
